package org.cuatrovientos.craps;
import java.util.Random;


/**
 * A press-your-luck game where you roll two dices and 
 * when you get the same in both you win.
 * @author Pello 
 *
 */
public class Craps {

	private static final int DICE_FACES = 6;
	private double money; // player money
	private double pbet; // players last bet
	private double betz; // total bets
	private Random rndom = new Random();
	private int d1, d2;
	
	/**
	 * @return the money
	 */
	public double getMoney() {
		return money;
	}

	/**
	 * @return the pbet
	 */
	public double getPbet() {
		return pbet;
	}

	/**
	 * @return the betz
	 */
	public double getBetz() {
		return betz;
	}

	/**
	 * @return the d1
	 */
	public int getD1() {
		return d1;
	}

	/**
	 * @return the d2
	 */
	public int getD2() {
		return d2;
	}

	/**
	 * constructor, player begins with initial money
	 * @param mymoney
	 */
	public Craps (double mymoney) {
		money = mymoney;
	}
	
	/**
	 * player puts bet, and we add random money from other players
	 */
	public void putb (double plbet) {
		pbet = plbet;
		betz = pbet + rndom.nextInt(100);
	}
	
	/**
	 * rolling two 6D dices...
	 */
	public void roll () {
		d1 = rndom.nextInt(DICE_FACES);
		d2 = rndom.nextInt(DICE_FACES);
	}
	
	/**
	 * tells if player wins or not
	 * @return
	 */
	public boolean winOrwhat () {
		return (d1==d2);
	}
	
	/**
	 * player loses we substract last bet from total money
	 */
	public void lose () {
		money -= pbet;
	}

	/**
	 * player wins all the money
	 */
	public void win () {
		money += betz;
	}
	
}
